﻿using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OpenAdmin.Core.DbContextLocators;
using OpenAdmin.Core.Enums;

namespace OpenAdmin.Core.Models;

/// <summary>
/// 广告位表
/// </summary>
[Table("Advertisements")]
public class Advertisement : EntityBase<MallDbContextLocator>, IEntityTypeConfigure<Advertisement>, IEntityTypeSeedDataConfigure<Advertisement>
{
    /// <summary>
    /// 广告类型
    /// </summary>
    public AdvertisementType Type { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 内容
    /// </summary>
    public string Content { get; set; }

    /// <summary>
    /// 图片地址
    /// </summary>
    public string Image { get; set; }

    /// <summary>
    /// 跳转地址
    /// </summary>
    public string Link { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; }

    public void Configure(EntityTypeBuilder<Advertisement> entityBuilder)
    {
        entityBuilder.Property(p => p.Title).HasMaxLength(64);
        entityBuilder.Property(p => p.Content).HasMaxLength(256);
        entityBuilder.Property(p => p.Image).HasMaxLength(128);
        entityBuilder.Property(p => p.Link).HasMaxLength(128);
    }

    public IEnumerable<Advertisement> HasData(DbContext dbContext)
    {
        return new List<Advertisement>
        {
            new Advertisement { Id = 1, Type = AdvertisementType.Banner, Title = "轮播标题一", Image = "https://s10.mogucdn.com/mlcdn/c45406/180926_45fkj8ifdj4l824l42dgf9hd0h495_750x390.jpg", Link = "https://act.mogujie.com/huanxin0001?acm=3.mce.2_10_1jhwa.43542.0.ccy5br4OlfK0Q.pos_0-m_454801-sd_119", Sort = 1, CreateTime = DateTime.Now },
            new Advertisement { Id = 2, Type = AdvertisementType.Banner, Title = "轮播标题二", Image = "https://s10.mogucdn.com/mlcdn/c45406/180926_31eb9h75jc217k7iej24i2dd0jba3_750x390.jpg", Link = "https://act.mogujie.com/ruqiu00001?acm=3.mce.2_10_1ji16.43542.0.ccy5br4OlfK0R.pos_1-m_454889-sd_119", Sort = 2, CreateTime = DateTime.Now },
            new Advertisement { Id = 3, Type = AdvertisementType.Banner, Title = "轮播标题三", Image = "https://s10.mogucdn.com/mlcdn/c45406/180919_3f62ijgkj656k2lj03dh0di4iflea_750x390.jpg", Link = "https://act.mogujie.com/huanji001?acm=3.mce.2_10_1jfj8.43542.0.ccy5br4OlfK0S.pos_2-m_453270-sd_119", Sort = 3, CreateTime = DateTime.Now },
            new Advertisement { Id = 4, Type = AdvertisementType.Banner, Title = "轮播标题四", Image = "https://s10.mogucdn.com/mlcdn/c45406/180917_18l981g6clk33fbl3833ja357aaa0_750x390.jpg", Link = "https://act.mogujie.com/liuxing00001?acm=3.mce.2_10_1jepe.43542.0.ccy5br4OlfK0T.pos_3-m_452733-sd_119", Sort = 4, CreateTime = DateTime.Now },
            new Advertisement { Id = 5, Type = AdvertisementType.Recommend, Title = "推荐标题一", Image = "https://s10.mogucdn.com/mlcdn/c45406/180913_036dli57aah85cb82l1jj722g887g_225x225.png", Link = "http://act.meilishuo.com/10dianlingquan?acm=3.mce.2_10_1dggc.13730.0.ccy5br4OlfK0U.pos_0-m_313898-sd_119", Sort = 1, CreateTime = DateTime.Now },
            new Advertisement { Id = 6, Type = AdvertisementType.Recommend, Title = "推荐标题二", Image = "https://s10.mogucdn.com/mlcdn/c45406/180913_25e804lk773hdk695c60cai492111_225x225.png", Link = "https://act.mogujie.com/tejiazhuanmai09?acm=3.mce.2_10_1dgge.13730.0.ccy5br4OlfK0V.pos_1-m_313899-sd_119", Sort = 2, CreateTime = DateTime.Now },
            new Advertisement { Id = 7, Type = AdvertisementType.Recommend, Title = "推荐标题三", Image = "https://s10.mogucdn.com/mlcdn/c45406/180913_387kgl3j21ff29lh04181iek48a6h_225x225.png", Link = "http://act.meilishuo.com/neigouful001?acm=3.mce.2_10_1b610.13730.0.ccy5br4OlfK0W.pos_2-m_260486-sd_119", Sort = 3, CreateTime = DateTime.Now },
            new Advertisement { Id = 8, Type = AdvertisementType.Recommend, Title = "推荐标题四", Image = "https://s10.mogucdn.com/mlcdn/c45406/180913_8d4e5adi8llg7c47lgh2291akiec7_225x225.png", Link = "http://act.meilishuo.com/wap/yxzc1?acm=3.mce.2_10_1dggg.13730.0.ccy5br4OlfK0X.pos_3-m_313900-sd_119", Sort = 4, CreateTime = DateTime.Now },
        };
    }
}
